<?php

namespace api\goods\controller;

class AdminOrderController extends \Aaa\goods\controller\AdminOrderController {

    protected $baseField = [
        [
            'field' => 'id',
            'name' => 'ID',
        ],
        [
            'field' => 'seller_id',
            'name' => '卖家ID',
            'view' => [
                'route' => 'user/AdminUser/view',
            ],
        ],
        [
            'field' => 'buyer_id',
            'name' => '买家ID',
            'view' => [
                'route' => 'user/AdminUser/view',
            ],
        ],
        [
            'field' => 'goods_id',
            'name' => '商品ID',
            'view' => [
                'route' => 'goods/AdminIndex/view',
            ],
        ],
        [
            'field' => 'delivery_type',
            'name' => '发货类型',
            'type' => 'radio',
            'options' => [
                ['name' => '卖家发货', 'value' => 0],
                ['name' => '平台代发', 'value' => 1],
            ],
        ],
        [
            'field' => 'status',
            'name' => '订单状态',
            'type' => 'radio',
            'options' => [
                ['name' => '待付款', 'value' => 0],
                ['name' => '待发货', 'value' => 1],
                ['name' => '交易中', 'value' => 2],
                ['name' => '已完成', 'value' => 3],
                ['name' => '已取消', 'value' => 4],
            ],
        ],
        [
            'field' => 'amount',
            'name' => '付款金额',
        ],
        [
            'field' => 'purchase_quantity',
            'name' => '购买数量',
        ],
        [
            'field' => 'compensation_id',
            'name' => '包赔服务',
            'type' => 'select',
            'options' => [
                ['name' => '无', 'value' => 0],
            ],
            'optionsSource' => [
                'table' => 'goods_compensation',
                'nameField' => 'name',
                'valueField' => 'id',
            ],
        ],
        [
            'field' => 'compensation_amount',
            'name' => '包赔服务金额',
        ],
        [
            'field' => 'mobile',
            'name' => '联系手机',
        ],
        [
            'field' => 'qq',
            'name' => '联系QQ',
        ],
        [
            'field' => 'wechat',
            'name' => '联系微信',
        ],
        [
            'field' => 'referral_code',
            'name' => '推荐码',
        ],
        [
            'field' => 'create_time',
            'name' => '下单时间',
            'type' => 'time',
        ],
        [
            'field' => 'status1_time',
            'name' => '付款时间',
            'type' => 'time',
        ],
        [
            'field' => 'status2_time',
            'name' => '收货时间',
            'type' => 'time',
        ],
        [
            'field' => 'status3_time',
            'name' => '收货时间',
            'type' => 'time',
        ],
        [
            'field' => 'status4_time',
            'name' => '取消时间',
            'type' => 'time',
        ],
        [
            'field' => 'cancellation_reason',
            'name' => '取消原因',
        ],
        [
            'field' => 'is_refund',
            'name' => '退款状态',
            'type' => 'switch',
            'options' => ['申请退款', '正常'],
        ],
        [
            'field' => 'refund_time',
            'name' => '退款时间',
            'type' => 'time',
        ],
        [
            'field' => 'refund_reason',
            'name' => '退款原因',
        ],
    ];

    protected function beforeIndex() {
        $this->actionField = [
            'id',
            'seller_id',
            'buyer_id',
            'goods_id',
            'delivery_type',
            'status',
            'amount',
            'purchase_quantity',
            'compensation_id',
            'compensation_amount',
            'mobile',
            'qq',
            'wechat',
            'referral_code',
            'create_time',
            'status1_time',
            'status2_time',
            'status3_time',
            'status4_time',
            'cancellation_reason',
            'is_refund',
            'refund_time',
            'refund_reason',
        ];
        $this->searchField = [
            'common' => [
                'id' => 'accurate',
                'seller_id' => 'accurate',
                'buyer_id' => 'accurate',
                'goods_id' => 'accurate',
                'delivery_type' => 'accurate',
                'status' => 'accurate',
                'compensation_id' => 'accurate',
                'cancellation_reason' => 'fuzzy',
                'is_refund' => 'accurate',
                'refund_reason' => 'fuzzy',
                'mobile' => 'fuzzy',
                'qq' => 'fuzzy',
                'wechat' => 'fuzzy',
                'referral_code' => 'accurate',
            ],
            'time' => ['create_time', 'status1_time', 'status2_time', 'status3_time', 'status4_time', 'refund_time',],
            'amount' => ['amount', 'purchase_quantity', 'compensation_amount',]
        ];
    }

    protected function beforeDelivery() {
        $this->beforeIndex();
    }

    protected function beforeEdit() {
        $this->actionField = [
            'seller_id',
            'buyer_id',
            'goods_id',
            'status',
            'cancellation_reason',
            'is_refund',
            'refund_reason',
            'amount',
            'purchase_quantity',
            'compensation_id',
            'compensation_amount',
            'mobile',
            'qq',
            'wechat',
            'referral_code',
            'create_time',
            'status1_time',
            'status2_time',
            'status3_time',
            'status4_time',
            'refund_time',
        ];
    }


}
